package com.example.m3;

import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

import javax.annotation.PostConstruct;

@SpringBootApplication
public class main {
    @Autowired
    private Producer producer;

    public static void main(String[] args) {
        SpringApplication.run(main.class, args);

    }

    @Bean
    public FanoutExchange logEx(){
        return new FanoutExchange("logs",false,false);
    }

    //    spring扫描完创建完所有的依赖实例，完成注入后,执行下面这个注解的方法
    @PostConstruct
    public void p() {
        new Thread(() -> producer.send()).start();
    }

}
